package com.cai.common.result;

import lombok.Data;

@Data
public class ResultVO {
    private int code;
    private Object data;
    private String message;

    public ResultVO(StatusCode statusCode) {
        this.code = statusCode.getCode();
        this.message = statusCode.getMessage();
    }

    public ResultVO(StatusCode statusCode, Object data) {
        this(statusCode);
        this.data = data;
    }

    public ResultVO(StatusCode statusCode, String message) {
        this(statusCode);
        this.message = message;
    }

    public static ResultVO ok(Object data) {
        return new ResultVO(StatusCode.SUCCESS, data);
    }

    public static ResultVO ok(StatusCode statusCode, Object data) {
        return new ResultVO(statusCode, data);
    }

    public static ResultVO ok() {
        return new ResultVO(StatusCode.SUCCESS);
    }

    public static ResultVO fail(Object data) {
        return new ResultVO(StatusCode.FAIL, data);
    }

    public static ResultVO fail() {
        return fail(StatusCode.FAIL);
    }

    public static ResultVO fail(StatusCode statusCode, Object data) {
        return new ResultVO(statusCode, data);
    }

    public static ResultVO fail(StatusCode statusCode, String message) {
        return new ResultVO(statusCode, message);
    }
}
